#include "cpu/exec/template-start.h"

#define instr cmp

/*static void do_execute() {
    DATA_TYPE src=op_src->val;
    DATA_TYPE dest=op_dest->val;
    DATA_TYPE result=dest-src;
    update_eflags_pf_zf_sf((DATA_TYPE_S) result);
    cpu.eflags.CF=(dest<src);
    cpu.eflags.ZF=(result==0);
    cpu.eflags.SF=MSB(result);
    cpu.eflags.OF=MSB((dest^src)&(dest^result));
    print_asm_template2();
}*/
static void do_execute() {
	DATA_TYPE result = op_dest->val - op_src->val;
	int len = (DATA_BYTE << 3) - 1;
    int s1,s2;
	s1=op_dest->val>>len;
	s2=op_src->val>>len;
    update_eflags_pf_zf_sf((DATA_TYPE_S) result);
    cpu.eflags.CF=op_dest->val<op_src->val;
	cpu.eflags.SF=result >> len;
    cpu.eflags.OF=(s1!=s2&&s2==cpu.eflags.SF);
    cpu.eflags.ZF=!result;
	result^=result>>4;
	result^=result>>2;
	result^=result>>1;
	cpu.eflags.PF=!(result&1);
	print_asm_template2();
}

make_instr_helper(r2rm)
make_instr_helper(rm2r)
make_instr_helper(i2rm)
make_instr_helper(i2a)

#if DATA_BYTE==2||DATA_BYTE==4
make_instr_helper(si2rm)
#endif

#include "cpu/exec/template-end.h"